package com.agua.enturno.vista.modelos;

import com.agua.enturno.util.JodaTimeUtils;
import org.apache.wicket.model.IModel;


public class TextDayOfWeekModel implements IModel<String> {
	
	private static final long serialVersionUID = 1L;
	
	private IModel<Integer> numericDayOfWeekModel;
	
	public TextDayOfWeekModel(IModel<Integer> numericDayOfWeekModel) {
		this.numericDayOfWeekModel = numericDayOfWeekModel;
	}

	@Override
	public void detach() {
		numericDayOfWeekModel.detach();
	}

	@Override
	public String getObject() {
		return JodaTimeUtils.getInstance().getTextDayOfWeek(numericDayOfWeekModel.getObject());
	}

	@Override
	public void setObject(String object) {
		this.numericDayOfWeekModel.setObject(JodaTimeUtils.getInstance().getIntDayOfWeek(object));
	}
	
}
